<?php
class Notes_model extends CI_Model {
	
	function __construct()
	{
		parent::__construct();
	}
	function getNotes ($cid)
	{
		$this->db->from('notes');
		$this->db->where('customerid',$cid);
		$this->db->order_by('id','asc');
		$res	= $this->db->get();
		$restr	= '';
		if($res && $res->num_rows()>0)
		{
			foreach($res->result() as $list)
			{
				$restr	.= $list->addtime."&nbsp;&nbsp;&nbsp;<font color='#FFA800'>".$list->name."</font><br />";
				$restr	.= nl2br($list->note)."<br />";
				$restr	.="<hr />";
			}
			return $restr;
		}
		else
		{
			return '';
		}
	}
	function addNote($cid,$note='')
	{
		$data	= array('customerid'=>$cid,'note'=>htmlspecialchars($note),'name'=>_gs('nickname'));
		if($this->db->insert('notes',$data))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}
 ?>